home *** CD-ROM | disk | FTP | other *** search
- ; ----------------------------------------------------------------------------
- ;
- ; CADENCE6 Recursion Examples Bill Kramer 10/86
- ;
- ;
- ; Recursive routine: CHANGE-TEXT
- ; Seach for a substring in a string, replace all occurances with
- ; with a new string.
- ;
- (defun change-text (olds news strng)
- (cond
- ((= olds (substr strng 1 (strlen olds)))
- (strcat
- news (change-text olds news (substr strng (1+ (strlen olds))))))
- ((= (strlen strng) 0) strng)
- (t (strcat (substr strng 1 1)
- (change-text olds news (substr strng 2))))))
- ; -----------------------------------------------------------
- ;
- ; Function: CHG-TEXT
- ; Show text entities to be changed, enter change strings and
- ; execute CHANGE-TEXT for each string.
- ;
- (defun c:chg-text ()
- (prompt "\nSelect text entities:")
- (setq ss nil) (gc) ; Clear the selection set.
- (setq ss (ssget)) ; Enter the items
- (setq olds (getstring "\nOld string value:"))
- (setq news (getstring "\nNew string value:"))
- (setq cnt 0 cmax (sslength ss)) ; Set up loop variables
- (while (< cnt cmax) ; Go through all of the selection set entities
- (setq ename (ssname ss cnt)) ; Get the next entity name from set
- (setq elist (entget ename)) ; Get the entity list.
- (cond
- ((= (cdr (assoc 0 elist)) "TEXT") ; List is text?
- (setq chgs (change-text olds news (cdr (assoc 1 elist))))
- (cond
- ((/= chgs (cdr (assoc 1 elist))) ; Text changed?
- (setq elist (subst (cons 1 chgs) (assoc 1 elist) elist))
- (entmod elist))))) ; Redisplay list.
- (setq cnt (1+ cnt))))
- ; -------------------------------
- ;
- ; Draw several insertions of a figure,
- ; Rotation and scaling is iteratively increased.
- ;
- (defun fungraphs (fig scl rot dscl drot insp cnt)
- (command "INSERT" fig insp scl "" rot)
- (cond
- ((> cnt 0)
- (fungraphs fig (+ scl dscl) (+ rot drot) dscl drot insp (1- cnt)))))